<template>
    <view class="signList">
            <view class="top flex_wrap row_middle row_between">
                <view class="flex_wrap row_middle pepole">
                    <u--image
						v-if="userDetails.avatar == 'null'"
                        :src="`/static/img/conference/MissingAvatar.png`"
                        shape="circle"
                        width="80"
                        height="80"
                    ></u--image>
					<u--image
						v-else
					    :src="
					        userDetails.avatar ||
					        `/static/img/conference/MissingAvatar.png`
					    "
					    shape="circle"
					    width="80"
					    height="80"
					></u--image>
                    <view style="width: 36rpx"></view>
                    <view class="flex_wrap flex_column left">
                        <view>
							<u--text
								v-if="userDetails.nickName == 'null'"
							    text="微信用户"
							    color="#FFF"
							    size="40rpx"
							/>
							<u--text
								v-else
                                :text="
                                    userDetails.nickName ||
                                    '微信用户'
                                "
                                color="#FFF"
                                size="40rpx"
							/>
						</view>
                        <view
                            ><u--text
                                :text="userDetails.customerPhone"
                                color="#FFF"
                                size="28rpx"
                                bold
                        /></view>
                    </view>
                </view>
            </view>
			<view class="cellBox">
				<view>
					<u--text
					v-if="chickenDetail.last_login_time == null"
				        :text="`最近上线时间：`+`--`"
				        color="#333"
				        size="28rpx"
						align="right"
						margin="0 0 18rpx 0"
					/>
					<u--text
					v-else
					    :text="`最近上线时间：`+`${chickenDetail.last_login_time}`"
					    color="#333"
					    size="28rpx"
						align="right"
						margin="0 0 18rpx 0"
					/>
				</view>
			    <view class="detail" >
			        <text class="detail_t">{{chickenDetail.chick_total+' 只'}}</text>
			    </view>
				<view class="detailEgg flex_wrap" @click="to_detail">
					<text class="detail_t">{{chickenDetail.egg_total+' 个'}}</text>
					<view class="detail_icon">
						<u-icon name="arrow-right" color="#fff" size="32rpx" label="查看明细" labelColor="#fff" labelPos="left" /></u-icon>
					</view>
				</view>
				<view class="detailFood">
					<text class="detail_t">{{chickenDetail.chick_food_total+' 袋'}}</text>
				</view>
			</view>
    </view>
</template>

<script>
import caches from "@/config/caches.js";
import { chickUrl } from "@/config/tendIdConfig.js";
import { encryption } from "@/utils/encryption.js";
export default {
    data() {
        return {
			cardNum:'2',
			phone:'',
			userDetails:{},
			chickenDetail:{}
        };
    },
    onLoad(options) {
        this.phone = options.customerPhone;
		this.userDetails = options
		this.chickenGame(this.phone)
    },

    methods: {
		to_detail(){
			uni.navigateTo({
				url:`/pages_my/user_manage/chickenList/detail?phone=${this.phone}`
			})
		},
		chickenGame(phone) {
		    // 使用 uni.request 替换 wx.request，支持跨平台
		    uni.request({
		        url:chickUrl + "/api/v1/open/chick/user-chick-property",
		        method: "GET",
		        data: {
					...encryption({
					    user_account: this.phone,
					}),
		        },
		        success: (res) => {
					this.chickenDetail = res.data.data
		        },
		        fail: (err) => {
		        },
		    });
		},
    },
};
</script>

<style lang="scss" scoped>
.signList {
    ::v-deep.u-line {
        height: auto !important;
    }
    position: relative;
}
.pepole {
    padding-left: 80rpx;
    padding-bottom: 64rpx;
}
.top {
    height: 372rpx;
    width: 100%;
    box-sizing: border-box;
    background-image: url("@/static/img/conference/userDetailsbg.png");
    background-size: cover;
}
.cellBox {
    width: 92vw;
    margin: 60rpx auto 0;
   .detail,.detailFood,.detailEgg {
		width: 100%;
		box-sizing: border-box;
		height: 198rpx;
		border-radius: 20rpx;
		background-image: url("https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/09/19/fc1f15443bc64255b1f851edf195473c.png");
		background-size: cover;
		margin-bottom: 40rpx;
		&_t{
			font-size: 36rpx;
			color: #FFFFFF;
			display: block;
			padding: 106rpx 0 0 80rpx;
		}
		&_icon{
			padding: 118rpx 0 0 100rpx;
		}
   }
   .detailFood{
		background-image: url("https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/09/19/2dd6362378e743019e3cebe7e17f2c5d.png");
   }
   .detailEgg{
		background-image: url("https://oneredhealth.oss-cn-hangzhou.aliyuncs.com/2023/09/19/a1849c45c6f5420d92dd5325fde4c66c.png");
   }
}
</style>
